<template>
  <a-modal
    :title="title"
    :after-close="reset"
    @ok="submit"
  >
    <a-form
      ref="formRef"
      :model="form"
      :rules="rules"
      :label-col="{style: { width: '80px' }}"
    >
                                                        <a-form-item label="订单号" name="orderId">
                    <a-input  v-model:value="form.orderId" placeholder="订单号"></a-input>
                </a-form-item>
                                                <a-form-item label="用户id" name="uid">
                    <a-input  v-model:value="form.uid" placeholder="用户id"></a-input>
                </a-form-item>
                                                <a-form-item label="用户姓名" name="realName">
                    <a-input  v-model:value="form.realName" placeholder="用户姓名"></a-input>
                </a-form-item>
                                                <a-form-item label="用户电话" name="userPhone">
                    <a-input  v-model:value="form.userPhone" placeholder="用户电话"></a-input>
                </a-form-item>
                                                <a-form-item label="详细地址" name="userAddress">
                    <a-input  v-model:value="form.userAddress" placeholder="详细地址"></a-input>
                </a-form-item>
                                                <a-form-item label="运费金额" name="freightPrice">
                    <a-input  v-model:value="form.freightPrice" placeholder="运费金额"></a-input>
                </a-form-item>
                                                <a-form-item label="订单商品总数" name="totalNum">
                    <a-input  v-model:value="form.totalNum" placeholder="订单商品总数"></a-input>
                </a-form-item>
                                                <a-form-item label="订单总价" name="totalPrice">
                    <a-input  v-model:value="form.totalPrice" placeholder="订单总价"></a-input>
                </a-form-item>
                                                <a-form-item label="邮费" name="totalPostage">
                    <a-input  v-model:value="form.totalPostage" placeholder="邮费"></a-input>
                </a-form-item>
                                                <a-form-item label="实际支付金额" name="payPrice">
                    <a-input  v-model:value="form.payPrice" placeholder="实际支付金额"></a-input>
                </a-form-item>
                                                <a-form-item label="支付邮费" name="payPostage">
                    <a-input  v-model:value="form.payPostage" placeholder="支付邮费"></a-input>
                </a-form-item>
                                                <a-form-item label="抵扣金额" name="deductionPrice">
                    <a-input  v-model:value="form.deductionPrice" placeholder="抵扣金额"></a-input>
                </a-form-item>
                                                <a-form-item label="优惠券id" name="couponId">
                    <a-input  v-model:value="form.couponId" placeholder="优惠券id"></a-input>
                </a-form-item>
                                                <a-form-item label="优惠券金额" name="couponPrice">
                    <a-input  v-model:value="form.couponPrice" placeholder="优惠券金额"></a-input>
                </a-form-item>
                                                <a-form-item label="支付状态" name="paid">
                    <a-input  v-model:value="form.paid" placeholder="支付状态"></a-input>
                </a-form-item>
                                                <a-form-item label="支付时间" name="payTime">
                    <a-input  v-model:value="form.payTime" placeholder="支付时间"></a-input>
                </a-form-item>
                                                <a-form-item label="支付方式" name="payType">
                    <a-input  v-model:value="form.payType" placeholder="支付方式"></a-input>
                </a-form-item>
                                                <a-form-item label="创建时间" name="createTime">
                    <a-input  v-model:value="form.createTime" placeholder="创建时间"></a-input>
                </a-form-item>
                                                <a-form-item label="订单状态（0：待发货；1：待收货；2：已收货，待评价；3：已完成；）" name="status">
                    <a-input  v-model:value="form.status" placeholder="订单状态（0：待发货；1：待收货；2：已收货，待评价；3：已完成；）"></a-input>
                </a-form-item>
                                                <a-form-item label="0 未退款 1 申请中 2 已退款 3 退款中" name="refundStatus">
                    <a-input  v-model:value="form.refundStatus" placeholder="0 未退款 1 申请中 2 已退款 3 退款中"></a-input>
                </a-form-item>
                                                <a-form-item label="退款图片" name="refundReasonWapImg">
                    <a-input  v-model:value="form.refundReasonWapImg" placeholder="退款图片"></a-input>
                </a-form-item>
                                                <a-form-item label="退款用户说明" name="refundReasonWapExplain">
                    <a-input  v-model:value="form.refundReasonWapExplain" placeholder="退款用户说明"></a-input>
                </a-form-item>
                                                <a-form-item label="前台退款原因" name="refundReasonWap">
                    <a-input  v-model:value="form.refundReasonWap" placeholder="前台退款原因"></a-input>
                </a-form-item>
                                                <a-form-item label="不退款的理由" name="refundReason">
                    <a-input  v-model:value="form.refundReason" placeholder="不退款的理由"></a-input>
                </a-form-item>
                                                <a-form-item label="退款时间" name="refundReasonTime">
                    <a-input  v-model:value="form.refundReasonTime" placeholder="退款时间"></a-input>
                </a-form-item>
                                                <a-form-item label="退款金额" name="refundPrice">
                    <a-input  v-model:value="form.refundPrice" placeholder="退款金额"></a-input>
                </a-form-item>
                                                <a-form-item label="快递名称/送货人姓名" name="deliveryName">
                    <a-input  v-model:value="form.deliveryName" placeholder="快递名称/送货人姓名"></a-input>
                </a-form-item>
                                                <a-form-item label="发货类型" name="deliveryType">
                    <a-input  v-model:value="form.deliveryType" placeholder="发货类型"></a-input>
                </a-form-item>
                                                <a-form-item label="快递单号/手机号" name="deliveryId">
                    <a-input  v-model:value="form.deliveryId" placeholder="快递单号/手机号"></a-input>
                </a-form-item>
                                                <a-form-item label="消费赚取积分" name="gainIntegral">
                    <a-input  v-model:value="form.gainIntegral" placeholder="消费赚取积分"></a-input>
                </a-form-item>
                                                <a-form-item label="使用积分" name="useIntegral">
                    <a-input  v-model:value="form.useIntegral" placeholder="使用积分"></a-input>
                </a-form-item>
                                                <a-form-item label="给用户退了多少积分" name="backIntegral">
                    <a-input  v-model:value="form.backIntegral" placeholder="给用户退了多少积分"></a-input>
                </a-form-item>
                                                <a-form-item label="备注" name="mark">
                    <a-input  v-model:value="form.mark" placeholder="备注"></a-input>
                </a-form-item>
                                                <a-form-item label="是否删除" name="isDel">
                    <a-input  v-model:value="form.isDel" placeholder="是否删除"></a-input>
                </a-form-item>
                                                <a-form-item label="管理员备注" name="remark">
                    <a-input  v-model:value="form.remark" placeholder="管理员备注"></a-input>
                </a-form-item>
                                                <a-form-item label="商户ID" name="merId">
                    <a-input  v-model:value="form.merId" placeholder="商户ID"></a-input>
                </a-form-item>
                                                <a-form-item label="" name="isMerCheck">
                    <a-input  v-model:value="form.isMerCheck" placeholder=""></a-input>
                </a-form-item>
                                                <a-form-item label="拼团商品id0一般商品" name="combinationId">
                    <a-input  v-model:value="form.combinationId" placeholder="拼团商品id0一般商品"></a-input>
                </a-form-item>
                                                <a-form-item label="拼团id 0没有拼团" name="pinkId">
                    <a-input  v-model:value="form.pinkId" placeholder="拼团id 0没有拼团"></a-input>
                </a-form-item>
                                                <a-form-item label="成本价" name="cost">
                    <a-input  v-model:value="form.cost" placeholder="成本价"></a-input>
                </a-form-item>
                                                <a-form-item label="秒杀商品ID" name="seckillId">
                    <a-input  v-model:value="form.seckillId" placeholder="秒杀商品ID"></a-input>
                </a-form-item>
                                                <a-form-item label="砍价id" name="bargainId">
                    <a-input  v-model:value="form.bargainId" placeholder="砍价id"></a-input>
                </a-form-item>
                                                <a-form-item label="核销码" name="verifyCode">
                    <a-input  v-model:value="form.verifyCode" placeholder="核销码"></a-input>
                </a-form-item>
                                                <a-form-item label="门店id" name="storeId">
                    <a-input  v-model:value="form.storeId" placeholder="门店id"></a-input>
                </a-form-item>
                                                <a-form-item label="配送方式 1=快递 ，2=门店自提" name="shippingType">
                    <a-input  v-model:value="form.shippingType" placeholder="配送方式 1=快递 ，2=门店自提"></a-input>
                </a-form-item>
                                                <a-form-item label="店员id/核销员id" name="clerkId">
                    <a-input  v-model:value="form.clerkId" placeholder="店员id/核销员id"></a-input>
                </a-form-item>
                                                <a-form-item label="支付渠道(0微信公众号1微信小程序2余额)" name="isChannel">
                    <a-input  v-model:value="form.isChannel" placeholder="支付渠道(0微信公众号1微信小程序2余额)"></a-input>
                </a-form-item>
                                                <a-form-item label="消息提醒" name="isRemind">
                    <a-input  v-model:value="form.isRemind" placeholder="消息提醒"></a-input>
                </a-form-item>
                                                <a-form-item label="后台是否删除" name="isSystemDel">
                    <a-input  v-model:value="form.isSystemDel" placeholder="后台是否删除"></a-input>
                </a-form-item>
                                                <a-form-item label="更新时间" name="updateTime">
                    <a-input  v-model:value="form.updateTime" placeholder="更新时间"></a-input>
                </a-form-item>
                                                <a-form-item label="快递公司简称" name="deliveryCode">
                    <a-input  v-model:value="form.deliveryCode" placeholder="快递公司简称"></a-input>
                </a-form-item>
                                                <a-form-item label="用户拼团活动id 0没有" name="bargainUserId">
                    <a-input  v-model:value="form.bargainUserId" placeholder="用户拼团活动id 0没有"></a-input>
                </a-form-item>
                                                <a-form-item label="订单类型:0-普通订单，1-视频号订单" name="type">
                    <a-input  v-model:value="form.type" placeholder="订单类型:0-普通订单，1-视频号订单"></a-input>
                </a-form-item>
                                                <a-form-item label="商品总价" name="proTotalPrice">
                    <a-input  v-model:value="form.proTotalPrice" placeholder="商品总价"></a-input>
                </a-form-item>
                                                <a-form-item label="改价前支付金额" name="beforePayPrice">
                    <a-input  v-model:value="form.beforePayPrice" placeholder="改价前支付金额"></a-input>
                </a-form-item>
                                                <a-form-item label="是否改价,0-否，1-是" name="isAlterPrice">
                    <a-input  v-model:value="form.isAlterPrice" placeholder="是否改价,0-否，1-是"></a-input>
                </a-form-item>
                                                <a-form-item label="商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号" name="outTradeNo">
                    <a-input  v-model:value="form.outTradeNo" placeholder="商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号"></a-input>
                </a-form-item>
                        </a-form>
  </a-modal>
</template>

<script setup lang="ts">
import { storeorderAddup, storeorderinfo } from './api';
import { storeorder, type Istoreorder } from './entity';
import { validReg } from '@/utils/validate';

const props = withDefaults(defineProps<{
  data: Partial<Istoreorder>
}>(),{
})
const title = computed(() => props.data.id ? '编辑' : '新增')
const { formRef, submit, close } = useDialog({ validCallback: save })

let form = $ref(new storeorder())
watchEffect(() => {
  if (props.data.id) {
    storeorderinfo(props.data.id).then(res => {
      form.setProps(res)
    })
  }
})

const rules = {
        storeorderName: [validReg('required', '请输入用户名')]
}

onMounted(() => {
})
const emit = defineEmits(['change'])
function save() {
    storeorderAddup(form).then(() => {
    AntMessage.success('保存成功')
    close()
    emit('change')
  })
}

function reset() {
  form = new storeorder()
}
</script>

<style lang="less"></style>